/**
 * Author: yuechao
 * 
 * Time: 2011-5-11 上午11:14:28
 * 
 * 单一查询条件统一结构
 * 
 */
package com.wontube.core.dao.mybatis;

import java.util.List;

public class Criterion {
	private String condition;
	private Object value;
	private Object secondValue;
	private boolean noValue;
	private boolean singleValue;
	private boolean betweenValue;
	private boolean listValue;
	private String typeHandler;

	public String getCondition() {
		return this.condition;
	}

	public Object getValue() {
		return this.value;
	}

	public Object getSecondValue() {
		return this.secondValue;
	}

	public boolean isNoValue() {
		return this.noValue;
	}

	public boolean isSingleValue() {
		return this.singleValue;
	}

	public boolean isBetweenValue() {
		return this.betweenValue;
	}

	public boolean isListValue() {
		return this.listValue;
	}

	public String getTypeHandler() {
		return this.typeHandler;
	}

	/**
	 * @param condition
	 *            条件
	 */
	public Criterion(String condition) {
		this.condition = condition;
		this.typeHandler = null;
		this.noValue = true;
	}

	/**
	 * @param condition
	 *            条件
	 * @param value
	 *            比较值
	 * @param typeHandler
	 */
	public Criterion(String condition, Object value, String typeHandler) {
		this.condition = condition;
		this.value = value;
		this.typeHandler = typeHandler;
		if (value instanceof List<?>) {
			this.listValue = true;
		} else {
			this.singleValue = true;
		}
	}

	/**
	 * 
	 * @param condition
	 *            条件
	 * @param value
	 *            比较值
	 */
	public Criterion(String condition, Object value) {
		this(condition, value, null);
	}

	/**
	 * @param condition
	 *            条件
	 * @param value
	 *            比较左值
	 * @param secondValue
	 *            比较的右值
	 * @param typeHandler
	 */
	public Criterion(String condition, Object value, Object secondValue,
			String typeHandler) {
		this.condition = condition;
		this.value = value;
		this.secondValue = secondValue;
		this.typeHandler = typeHandler;
		this.betweenValue = true;
	}

	/**
	 * @param condition
	 *            条件
	 * @param value
	 *            比较左值
	 * @param secondValue
	 *            比较的右值
	 */
	public Criterion(String condition, Object value, Object secondValue) {
		this(condition, value, secondValue, null);
	}
}
